﻿using System;
using System.Collections.Generic;
using DomainModel.Utils;

namespace DomainModel.Domain.Bases
{
    public class IntIdentity : ValueObject<IntIdentity>, IEquatable<IntIdentity>
    {
        public int Id { get; private set; }
                                    
        public IntIdentity(int id)
        {
            Id = id;
        }

        internal IntIdentity()
        {
        }

        public override string ToString()

        {
            

            return string.Format("Id: {0}", Id);
        }


        public bool Equals(IntIdentity other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return other.Id == Id;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            IntIdentity intIdentity = obj as IntIdentity;
            if (intIdentity == null)
            {
                return false;
            }
            return Equals((IntIdentity) obj);
        }

        public override int GetHashCode()
        {
            return Id;
        }

        public static bool operator ==(IntIdentity left, IntIdentity right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(IntIdentity left, IntIdentity right)
        {
            return !Equals(left, right);
        }
    }
}